import { math } from "cc";
import { GameController } from "../game_controller";
import { HandCard } from "../view/hand_card";
import { GameSubState } from "../view/main_view";

export class Player{
    user_id:number;
    user_name:string;
    is_homeowner:boolean;
    is_me:boolean;
    is_alive:boolean = true;
    is_hang:boolean;
    hang_state_time:number;
    hang_state_action:number;
    extra_turn_num:number;
    card_type_list:Array<number>;
    pick_boom:boolean;
    constructor(user_id:number, user_name:string, is_homeowner:boolean, is_me:boolean){
        this.user_id = user_id;
        this.user_name = user_name;
        this.is_homeowner = is_homeowner;
        this.is_me = is_me;
        this.extra_turn_num = 0;
        this.pick_boom = false;
        this.card_type_list = new Array<number>();
    }

    PushCardType(card_type:number){
        this.card_type_list.push(card_type);
    }

    RemoveCardIndex(card_index:number){
        this.card_type_list.splice(card_index, 1);   
    }

    AddExtraTurnNum(num:number){
        this.extra_turn_num = this.extra_turn_num + 1;
    }

    SubExtraTurnNum(num:number){
        this.extra_turn_num = this.extra_turn_num - 1;
    }

    PickBoom(){
        this.pick_boom = true;
    }

    DefuseBoom(){
        this.pick_boom = false;
    }

    SetHang(is_hang:boolean){
        this.is_hang = is_hang;
    }

    PrepareHang(){
        this.hang_state_time = math.randomRangeInt(3, 9);
        this.hang_state_action = math.randomRangeInt(1, 3);
    }
}